package com.ddlaw.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ddlaw.entity.TLawyerServiceType;
import com.ddlaw.entity.TStudentApply;
import com.ddlaw.entity.TUsers;
import com.ddlaw.service.LawyerApplyService;
import com.ddlaw.service.LawyerTypeService;
import com.ddlaw.service.ProvinceService;
import com.ddlaw.service.UserService;

@Controller
@RequestMapping(value="/other")
public class OtherLawyerController extends BaseController{
	
	@Resource
	ProvinceService provinceService;
	@Resource
	LawyerTypeService lawyerTypeService;
	@Resource
	UserService userService;
	@Resource
	LawyerApplyService applyService;
	
	/**
	 * 其他法律人士申请页面
	 * @param model		模型数据
	 * @return
	 */
	@RequestMapping(value="register",method=RequestMethod.GET)
	public String register(Model model){
		TUsers  users = (TUsers)getHttpSession().getAttribute("user");
		if (users == null) {
			return "user/login";
		}
		List<TLawyerServiceType> lawyerTypes = lawyerTypeService.getLawyerServiveType(0);
		model.addAttribute("lawyerTypes",lawyerTypes );
		return "student/apply";
	}
	
	/**
	 * 律师申请信息录入(其他法律人士)
	 * @param lawyersApply		律师详细信息
	 * @return		录入申请表
	 */
	@RequestMapping(value="register",method=RequestMethod.POST)
	public String applyLawyer(TStudentApply othersApply, Model model){
		TUsers  users = (TUsers)getHttpSession().getAttribute("user");
		if (users == null) {
			return "user/login";
		}
		othersApply.setUserid(users.getUserid());
		applyService.addOtherApply(othersApply);
		model.addAttribute("name", othersApply.getName());
		return "user/suc";
	}
}
